#-#-Makefile-#- vim:syntax=make
###
 # @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
 ##

SM16CF ?= /dev/ttyUSB0

TOSMAKE_PROGRAMMER_TYPE = sm16cf
PROGRAMMER = sm16cf

program: setid FORCE
	@echo -e '$(INFO_STRING) installing $(TARGET) binary using sm16cf'
	$(PROGRAMMER) --baud-rate=57600 --device=$(SM16CF) --input-file=$(INSTALL_SREC) --flash-program

program_bl: setid FORCE
	@echo -e '$(INFO_STRING) installing $(PLATFORM) with bootloader using sm16cf'
	srec_cat $(BOOTLOADER_IMG) $(INSTALL_SREC) -exclude 0x000FFFDC 0x00100000 -o $(TOSMAKE_BUILD_DIR)/main_boot.srec -CRLF
	sed '/S5/d' $(TOSMAKE_BUILD_DIR)/main_boot.srec > $(TOSMAKE_BUILD_DIR)/main_boot2.srec
	$(PROGRAMMER) --baud-rate=57600 --device=$(SM16CF) --input-file=$(TOSMAKE_BUILD_DIR)/main_boot2.srec --flash-program
	rm $(TOSMAKE_BUILD_DIR)/main_boot.srec
	rm $(TOSMAKE_BUILD_DIR)/main_boot2.srec
